package fr.neyb.wesb.core.job.impl;

import java.util.List;

import fr.neyb.wesb.core.data.descriptors.record.RecordDescriptor;
import fr.neyb.wesb.core.data.io.RecordReader;
import fr.neyb.wesb.core.data.io.RecordWriter;
import fr.neyb.wesb.core.job.RunningState;
import fr.neyb.wesb.core.job.runner.JobsRunner;

public abstract class UnitJob extends AbstractJob {

	public UnitJob(List<RecordDescriptor> inputsDescriptors,
			List<RecordDescriptor> outputsDescriptors) {
		super(inputsDescriptors, outputsDescriptors);
	}

	@Override
	public synchronized final void run(JobsRunner runner) {
		currentState = RunningState.RUNNING;
		doJob(readers, writers);
		End(runner);
	}

	protected abstract void doJob(List<RecordReader> readers,
			List<RecordWriter> writers);

}
